#!/usr/bin/bash

# TODO: required=TRUE should not be required
# https://github.com/rstudio/reticulate/issues/791

export TF_CPP_MIN_LOG_LEVEL=2
  # 0 = all messages are logged (default behavior)
  # 1 = INFO messages are not printed
  # 2 = INFO and WARNING messages are not printed
  # 3 = INFO, WARNING, and ERROR messages are not printed


TF_VER="2.7"
TMPDIR="/tmp/r-keras-tests/tf-$TF_VER-cpu/"
mkdir -p $TMPDIR
rsync -a --delete . $TMPDIR

export RETICULATE_PYTHON=$(Rscript -e "cat(normalizePath(file.path(reticulate::miniconda_path(), 'envs/tf-$TF_VER-cpu/bin/python')))")

gnome-terminal --title="keras test: tf $i" --working-directory=$TMPDIR -- \
  Rscript -e "{cat('\n\n\n'); devtools::check(document=FALSE); cat('Done!\n'); scan('stdin', nlines=1)}"
